Polygon

interface Polygon<V : Vector<V>> : Spatial(source)

Represents a polygon in a vector space.

A polygon is defined by an ordered list of vertices that form a closed shape. The polygon can exist in any dimensional space (2D, 3D, etc.) as determined by the vector type.

Parameters

V

The type of vector representing the vertices of the polygon.

Inheritors

Properties

Link copied to clipboard
open val vertexCount: Int

Returns the number of vertices in the polygon.

Link copied to clipboard
abstract val vertices: List<V>

Returns the list of vertices defining the polygon.

Functions

Link copied to clipboard
abstract fun area(): Double

Computes the area of the polygon.

Link copied to clipboard
abstract fun centroid(): V

Computes the centroid (geometric center) of the polygon.

Link copied to clipboard
abstract fun contains(point: V): Boolean

Checks if a point is inside the polygon.

Link copied to clipboard
abstract fun dimensions(): Int

Returns the number of dimensions of the spatial object.

Link copied to clipboard
abstract fun isConvex(): Boolean

Checks if the polygon is convex.

Link copied to clipboard
abstract fun isFinite(): Boolean

Returns true if all values in the spatial are finite.

Link copied to clipboard
abstract fun isInfinite(): Boolean

Returns true if any value in the spatial is infinite.

Link copied to clipboard
abstract fun isNaN(): Boolean

Returns true if any value in the spatial is NaN (Not a Number).

Link copied to clipboard
abstract fun isSimple(): Boolean

Checks if the polygon is simple (non-self-intersecting).

Link copied to clipboard
abstract fun perimeter(): Double

Computes the perimeter of the polygon.

Link copied to clipboard
abstract fun reverse(): Polygon<V>

Reverses the order of vertices, effectively reversing the orientation of the polygon.

Link copied to clipboard
abstract fun scale(factor: Double, center: V): Polygon<V>

Scales the polygon by a given factor around a center point.

Link copied to clipboard
abstract fun signedArea(): Double

Computes the signed area of the polygon.

Link copied to clipboard
abstract fun transform(transformer: Transformer<V>): Polygon<V>

Transforms the polygon by applying a transformation to all vertices.

Link copied to clipboard
abstract fun translate(offset: V): Polygon<V>

Translates the polygon by a given offset vector.